package com.demo.attBcollectionapi;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

import com.demo.domain.Name;

public class CollectionDemo {
	
	private static final Name[] NAMES = new Name[] {
        new Name("Sally", "Smith"),
        new Name("Sulei", "Zhang")
    };
    
	static void removeIfDemo(){
		List<Name> list = new ArrayList<>();
		for (Name name : NAMES) {
		    list.add(name);
		}
		Predicate<Name> pred1 = name -> "Sally".equals(name.firstName);
		Predicate<Name> pred2 = name -> "Queue".equals(name.lastName);
		list.removeIf(pred1.or(pred2));
		list.forEach(name -> System.out.println(name.getFirstName()));
	}
	
	public static void main(String[] args) {
		removeIfDemo();
	}

}
